#pragma once
#include <windows.h>
/*
	Author: Dao Anh Vu
*/

class ByteQueue
{
	public:
		HANDLE hEvent_not_empty;
		HANDLE hEvent_not_full;

	private:
		BYTE *queue;
		int capacity;
		int size;
		int head;
		int tail;
		
		CRITICAL_SECTION mLock;

	public:
		ByteQueue(int cap = 1);
		~ByteQueue(void);

		int getSize();
		HANDLE getEvent() const;
		BOOL isFull();
		BOOL isEmpty();
		void waitWhileFull();
		void waitWhileEmpty();
		void add(BYTE b);
		void add(BYTE b[], int len);
		BYTE remove();
		void remove(BYTE b[], int &len);
};

